const mongoose = require('mongoose');

const goodsSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true
  },
  category: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Category',
    required: true
  },
  price: {
    type: Number,
    required: true
  },
  originalPrice: Number,
  images: [String],
  description: String,
  specs: [{
    name: String,
    values: [String]
  }],
  stock: {
    type: Number,
    default: 0
  },
  sales: {
    type: Number,
    default: 0
  },
  status: {
    type: Number,
    default: 1 // 1: 上架, 0: 下架
  },
  isRecommend: {
    type: Boolean,
    default: false
  },
  createdAt: {
    type: Date,
    default: Date.now
  }
});

module.exports = mongoose.model('Goods', goodsSchema); 